//
//  MyInvoiceTableViewCell.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/19.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "MyInvoiceTableViewCell.h"

@interface MyInvoiceTableViewCell ()
{
    GLGWLabel *tipsLabl;
    GLGWImageView *tipImgV;
    GLGWLabel *cardNumLabel;
    GLGWLabel *bankNameLabel;
    GLGWLabel *moneyLabel;
    GLGWLabel *timeLabel;
}

@end

@implementation MyInvoiceTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor whiteColor];
        GLGWView *baView = [[GLGWView alloc] initWithInSuperView:self];
        [baView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(kHeightProportion_In_iPhoneTriploid(15)));
            make.left.equalTo(self).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(94)));
        }];
        [baView setViewShadowWidth:6 theCornerRadius:6];
        baView.backgroundColor = [UIColor whiteColor];
        
        GLGWLabel *cardNumLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:baView];
        cardNumLab.text = @"622202020005611";
        [cardNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(baView).offset(-kWidthProportion_In_iPhoneTriploid(52));
            make.left.equalTo(baView).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(baView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        cardNumLabel = cardNumLab;
        
        GLGWLabel *bankNameLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:baView];
        bankNameLab.text = @"增值税发票";
        [bankNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cardNumLab.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.right.equalTo(baView.mas_right);
            make.left.equalTo(cardNumLab.mas_left);
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        bankNameLabel = bankNameLab;
        
        GLGWLabel *moneyLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:baView];
        NSString *str = @"¥3030";
        moneyLab.attributedText = [GLGWLabel bllChangeStr:str changewithStr:@"¥" changeColoer:[UIColor colorWithHexString:@"#EC5353"] withFont:SYSTEMFONT(12)];
        [moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(baView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(14));
            make.bottom.equalTo(baView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        moneyLabel = moneyLab;
        
        GLGWLabel *timeLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:baView];
        timeLab.text = @"2018-08-21 12:12:12";
        [timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.lessThanOrEqualTo(moneyLab.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(5));
            make.top.equalTo(bankNameLab.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.left.equalTo(cardNumLab.mas_left);
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        timeLabel = timeLab;
        
        GLGWLabel *tipLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#FFFFFF"] inSuperView:self];
        tipLab.text = @"已开票";
        [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(12));
            make.top.equalTo(baView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(54)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(18)));
        }];
        tipLab.backgroundColor = [UIColor colorWithHexString:@"#A89A60"];
        tipLab.textAlignment = NSTextAlignmentCenter;
        tipsLabl = tipLab;
        
        GLGWImageView *imgV = [[GLGWImageView alloc] initWithImageName:@"ToAudit" inSuperView:self];
        [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(tipLab.mas_bottom);
            make.left.equalTo(baView.mas_right);
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(3)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(1)));
        }];
        tipImgV = imgV;
        
    }
    return self;
}

- (void)setType:(MyInvoiceType)type
{
    _type = type;
    if (type == MyInvoiceType_WaitingFor) {
        tipImgV.image = [UIImage imageNamed:@"AuditFailure"];
        tipsLabl.text = @"待开票";
        tipsLabl.backgroundColor = [UIColor colorWithHexString:@"#EC5353"];
    } else if (type == MyInvoiceType_Haved) {
        tipImgV.image = [UIImage imageNamed:@"HaveWithdrawal"];
        tipsLabl.text = @"已开票";
        tipsLabl.backgroundColor = [UIColor colorWithHexString:@"#A89A60"];
    }
}

- (void)setDeModel:(MyInvoiceListDetailModel *)deModel
{
    _deModel = deModel;
//    cardNumLabel.text = deModel
    bankNameLabel.text = deModel.invoiceType;
    NSString *str = [NSString stringWithFormat:@"¥%@",deModel.applyMoney];
    moneyLabel.attributedText = [GLGWLabel bllChangeStr:str changewithStr:@"¥" changeColoer:[UIColor colorWithHexString:@"#EC5353"] withFont:SYSTEMFONT(12)];
    timeLabel.text = deModel.createTime;
    // 还有一个发票状态，这个再确认吧
}


@end
